package com.bilibili.service.impl;

import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.bilibili.dao.DataCenterDao;
import com.bilibili.dao.impl.DataCenterDaoImpl;
import com.bilibili.service.DataCenterService;

public class DataCenterServiceImpl implements DataCenterService {
	DataCenterDao dcs = new DataCenterDaoImpl();
	

	@Override
	public Map<String, Object> getChartData(String timeRange, String dataType, String category) {
		Map<String, Object> result = new HashMap<>();
		// 根据dataType决定返回哪些数据
		switch (dataType) {
		case "all": // 返回所有类型数据
			result.put("playTrend", dcs.queryPlayTrend(timeRange, category));// 播放
			result.put("fanGrowthTrend", dcs.queryFanGrowthTrend(timeRange, category));// 粉丝
			result.put("genderDistribution", dcs.queryGenderDistribution(timeRange, category));// 性别
			result.put("ageDistribution", dcs.queryAgeDistribution(timeRange, category));// 年龄
			result.put("detailedData", dcs.queryDetailedData(timeRange, category));// 统计
			break;
		case "play":// 返回播放相关数据
			result.put("playTrend", dcs.queryPlayTrend(timeRange, category));// 播放
			result.put("detailedData", dcs.queryDetailedData(timeRange, category));// 统计
			break;
		case "fan":// 返回粉丝相关数据
			result.put("fanGrowthTrend", dcs.queryFanGrowthTrend(timeRange, category));// 粉丝
			result.put("genderDistribution", dcs.queryGenderDistribution(timeRange, category));// 性别
			result.put("ageDistribution", dcs.queryAgeDistribution(timeRange, category));// 年龄
			break;
		default:
			System.out.println("没有数据");
		}
		return result;
	}

	@Override
	public Map<String, Object> getStatistics(String timeRange, String category) {
		// TODO Auto-generated method stub
		Map<String, Object> result = new HashMap<>();
		result.put("totalPlayCount", dcs.getTotalPlayCount(timeRange, category));
		result.put("fanCount", dcs.getFanCount(timeRange, category));
		return result;
	}

	@Override
	public Map<String, Object> getChartData(String timeRange, String dataType, String category, int userId) {
		Map<String, Object> result = new HashMap<>();
		// 根据dataType决定返回哪些数据
		switch (dataType) {
		case "all": // 返回所有类型数据
			result.put("playTrend", dcs.queryPlayTrend(timeRange, category, userId));// 播放
			result.put("fanGrowthTrend", dcs.queryFanGrowthTrend(timeRange, category, userId));// 粉丝
			result.put("genderDistribution", dcs.queryGenderDistribution(timeRange, category, userId));// 性别
			result.put("ageDistribution", dcs.queryAgeDistribution(timeRange, category, userId));// 年龄
			result.put("detailedData", dcs.queryDetailedData(timeRange, category));// 统计
			break;
		case "play":// 返回播放相关数据
			result.put("playTrend", dcs.queryPlayTrend(timeRange, category, userId));// 播放
			result.put("detailedData", dcs.queryDetailedData(timeRange, category));// 统计
			break;
		case "fan":// 返回粉丝相关数据
			result.put("fanGrowthTrend", dcs.queryFanGrowthTrend(timeRange, category, userId));// 粉丝
			result.put("genderDistribution", dcs.queryGenderDistribution(timeRange, category, userId));// 性别
			result.put("ageDistribution", dcs.queryAgeDistribution(timeRange, category, userId));// 年龄
			break;
		default:
			System.out.println("没有数据");
		}
		return result;
	}

	@Override
	public Map<String, Object> getStatistics(String timeRange, String category, int userId) {
		// TODO Auto-generated method stub
		Map<String, Object> result = new HashMap<>();
		result.put("totalPlayCount", dcs.getTotalPlayCount(timeRange, category));
		result.put("fanCount", dcs.getFanCount(timeRange, category, userId));
		return result;
	}

}
